package com.data.controllers;

import com.data.controllers.response.BaseResponse;
import com.data.dto.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user/")
public class UserController {

    @Autowired
    private RedisTemplate<String, User> redis;

    @PostMapping("saveUser")
    public BaseResponse saveUser(){
        HashOperations<String, String, User> hashOps = redis.opsForHash();
        hashOps.putIfAbsent("aaaa","123",new User(123,"1111","2222","3333"));
        return BaseResponse.build("save ok", 1);
    }

}
